package com.example.bean;

import com.alibaba.fastjson.JSONArray;
import lombok.Data;
import util.UidCtrl;
import util.UtilTime;

import java.util.List;

@Data
public class LoginV {
    private int error_code;
    private UserInfo user_info;
    private String uid;
    private JSONArray need_info;
    private JSONArray release_info;

    public LoginV(UserInfo userInfo) {
        error_code = 0;
        this.user_info = userInfo;
        need_info = new JSONArray();
        release_info = new JSONArray();
        uid = UidCtrl.getUid(userInfo.getAccount());
        List<GoodsBriefV> query = GoodsBriefV.getGBVList(userInfo.getAccount());
        if (query != null) {
            for (GoodsBriefV goodsBriefV : query) {
                if (goodsBriefV.getType() == 0) {
                    need_info.add(goodsBriefV);
                } else if (goodsBriefV.getType() == 1) {
                    release_info.add(goodsBriefV);
                } else {
                    throw new RuntimeException("goodsBriefV type wrong :" + goodsBriefV + UtilTime.getStringTimeNow());
                }
            }
        }
    }
}
